from drg_group.yinchuan_2023.Base import message,intersect,SS_VALID
from drg_group.yinchuan_2023.DRG import MDCR_DRG

def group(record):
  adrg_zd=["C76.101","C76.300","C76.305","C77.200","C77.300x001","C77.400x001","C77.900","C77.900x001","C78.604","C79.800x816","C79.811","C79.900x001","C80.000","C80.000x001","C80.001","C80.902","C81.000","C81.200","C81.900","C82.900","C83.000","C83.300","C83.300x006","C85.100","C85.701","C85.709","C85.900","C85.900x002","C85.900x005","C85.900x006","C85.900x009","C85.900x010","C85.900x011","C85.900x015","C85.900x019","C85.900x024","C85.900x025","C85.900x030","C86.000","C86.601","C88.000","C90.000","C90.000x024","C90.000x028","C90.000x038","C90.000x040","C90.100x002","C96.600","C96.601","C96.900","C97.x00","C97.x01","D45.x00","D46.200","D46.500","D46.700","D46.700x003","D47.200","D47.300","D47.700","D47.700x007","D47.900","D48.700x001","D48.716","D89.801","Q85.909"]
  adrg_zd1=[]
  adrg_ss=["01.5106","01.5900x043","01.5901","01.5902","01.5911","01.5913","01.6x00","03.0900x007","17.3300","32.2001","34.3x04","40.5000","40.5100","40.5400x001","40.5909","40.5910","40.5912","41.5x01","42.5200x005","43.9901","45.4103","45.6201","45.7300x007","45.7304","45.7601","45.9100x006","45.9301","54.1903","54.4x00x007","54.4x00x012","54.4x00x035","54.4x02","54.4x06","54.4x15","54.5100x009","54.5101","54.5901","54.5904","54.9900x010","55.5104","57.5901","57.8900x001","65.6300","68.4100","68.4101","68.4901"]
  adrg_ss1=[]
  adrg_ss2=[]
  dept_list=[]
  if True and record.zdList[0] in adrg_zd and record.ssList and record.ssList[0] in adrg_ss and record.ssList and intersect(record.ssList,adrg_ss):
    message('符合RA1入组条件，匹配规则：主诊断匹配、主手术匹配、某一手术匹配')
    
    if MDCR_DRG.RA19_group(record):
      return 'RA19'

    return 'RA1'
  else:
    return ''

